package com.qf.dao.sys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qf.api.sys.entity.SysUserEntity;
import com.qf.api.sys.vo.UserPageVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author: sin
 * @Date: 2025/5/21 21:17
 * @Description:
 **/
@Mapper
public interface SysUserMapper extends BaseMapper<SysUserEntity> {
    SysUserEntity selectByUsername(@Param("username") String username);

    List<UserPageVO> queryUser(@Param("username") String username,
                               @Param("mobile") String mobile,
                               @Param("status") Integer status);

    Long getUserRoleIds(Long userId);

    SysUserEntity getUserByUsername(@Param("username") String username);

    @Update("UPDATE sys_user SET avatar = #{avatar} WHERE id = #{userId} ")
    int uploadAvatar(@Param("avatar") String avatar, @Param(value = "userId") Long userId);

    @Update("UPDATE sys_user SET password = #{encode} WHERE id = #{userId} ")
    int updatePassword(@Param("userId") Long userId,@Param("encode") String encode);

    int updateCurrentUserInfo(@Param("userId") Long userId, @Param("nickname") String nickname, @Param("mobile") String mobile, @Param("email") String email, @Param("gender") Integer gender);

    @Update(("UPDATE sys_user SET status = #{status} where id = #{id}"))
    int updateUserStatus(@Param("id") Long id, @Param("status") Integer status);
}
